import operator
import time
from osv import osv, fields
from osv.orm import intersect
import tools.sql
from tools import config
from tools.translate import _
from mx import DateTime
import mx.DateTime
from mx.DateTime import RelativeDateTime, now, DateTime, localtime



class kdvn_4_digit_po(osv.osv):
    _name = "kdvn.4.digit.po"
    _description = "KDVN 4 Digit Po"
    _auto=False
    _order = "order_id"
    _columns = {
                'order_id': fields.many2one('purchase.order','Order',select=1),
                'description':fields.char('Description',size=250),
                'po_date': fields.date('Purchase Date',select=1)
                }

#CREATE OR REPLACE VIEW kdvn_4_digit_po AS
#SELECT  distinct
#    po.id as id,
#    po.id as order_id,
#    po.notes as description,
#    po.date_order AS po_date
# FROM 
#    purchase_order po
#left join
#    purchase_typeoforder pt on typeoforder=pt.id
# left join
#    purchase_order_line pol on po.id = pol.order_id
#left join
#    product_product pp on product_id = pp.id
# WHERE 
#    Length(pp.default_code::text) < 8 and po.date_order>'2012/04/01' and code<>'e'
#     and pp.default_code not like '3%' and pp.default_code not like '4%'
kdvn_4_digit_po()


